package maze;

public class Barcode {

	private Coordinate coordinate;
	private String code;
	private int direction;
	
	/**
	 * 
	 *
	 * @param xPos
	 * @param yPos
	 * @param BC The barcode to add, 8 chars: 0(black) or 1(white)
	 * @param direction 0: left to right, 1: top to bottom
	 */
	public Barcode(Coordinate coordinate, String BC, int direction){
		this.coordinate = coordinate;
		this.code =BC;
		this.direction = direction;
	}
	
	public int getX(){
		return coordinate.x;
	}
	
	public int getY(){
		return coordinate.y;
	}
	
	public Coordinate getPosition(){
		return coordinate;
	}
	
	public String getCode(){
		return code;
	}
	
	public int getDirection(){
		return direction;
	}
	@Override
	public boolean equals(Object code){
		StringBuffer reverser = new StringBuffer(((Barcode)code).getCode());   //Die overeenkomt zoals nodig voor addBarcode
		String reverseCode = new String(reverser.reverse());
		return ((Barcode)code).getCode().equals(this.getCode())||((Barcode)code).getCode().equals(reverseCode);	
	}
	public Direction getInDirection(){
		switch(getDirection()) {
		case 1:
			return Direction.SOUTH;
		case 2:
			return Direction.WEST;
		case 3:
			return Direction.NORTH;
		default:
			return Direction.EAST;
		}
	}
	
}
